<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@include file="/resource/common/taglib.jspf"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>${SESSION_COMPANY}-修改密码</title>
<%@include file="/resource/common/jquery.jspf"%>
<%@include file="/resource/common/commonCss.jspf"%>
<%@include file="/resource/common/bootstrap.jspf"%>
<%@include file="/resource/common/validate.jspf"%>
<%@include file="/resource/common/showLoading.jspf"%>
<script type="text/javascript">
	var PATH = "${ctx}";
</script>

<script type="text/javascript">
	var result = 0;
	var validateForm;
	function doSubmit() {
		if (validateForm.form()) {
			saveForum();
			return true;
		}
		return false;
	}
	$(function() {
		validateForm = $("#inputForm").validate({
			rules : {
				old_password : {
					required : true,
					minlength : 6,
					maxlength : 18
				},
				new_password : {
					required : true,
					minlength : 6,
					maxlength : 18
				},
				confirm_password : {
					required : true,
					minlength : 6,
					maxlength : 18,
					equalTo : "#new_password"
				}
			},
			messages : {
				old_password : {
					required : "请输入原密码",
					minlength : "密码长度不能小于6个字符",
					maxlength : "密码长度不能大于18个字符"
				},
				new_password : {
					required : "请输入新密码",
					minlength : "密码长度不能小于6个字符",
					maxlength : "密码长度不能大于18个字符"
				},
				confirm_password : {
					required : "请输入确认密码",
					minlength : "密码长度不能小于6个字符",
					maxlength : "密码长度不能大于18个字符",
					equalTo : "输入的确认密码与密码不一致"
				}
			},
			submitHandler : function() {
				updatePassword();
			},
			errorElement : "em",
			errorClass : "validate_error",
			submitHandler : function(form) { //通过之后回调
				saveForum();
			},
			invalidHandler : function(form, validator) {
				return false;
			}
		});

	});

	function asyncResult() {
		return $("#asyncResult").val();
	}

	function saveForum() {
		var array = {};
		var arrs = $('#inputForm').serializeArray();
		for ( var item in arrs) {
			if (arrs[item].name != 'ctime' && arrs[item].name != 'texts') {
				array[arrs[item].name] = arrs[item].value;
			}
		}
		$.ajax({
			headers : {
				'Accept' : 'application/json',
				'Content-Type' : 'application/json'
			},
			url : "updateSysUserPasswordJson.do",
			type : "post",
			data : JSON.stringify(array),
			async : true,
			dataType : "json"
		}).done(function(data) {
			if (data != null) {
				if (data.ret == 1) {
					top.layer.msg('修改密码成功.......', {
						time : 1000,
						icon : 6
					});
					$("#asyncResult").val(data.ret);
				} else {
					top.layer.alert('修改密码失败....' + data.msg, {
						skin : 'layui-layer-lan',
						closeBtn : 0,
						anim : 4,
						icon : 5
					});
				}
			}
			$("body").hideLoading();
		}).fail(function(data) {
			top.layer.alert('修改密码失败.访问系统不正常...', {
				skin : 'layui-layer-lan',
				closeBtn : 0,
				anim : 4,
				icon : 5
			});
			$("#asyncResult").val(-110);
			$("body").hideLoading();
		});
	}
</script>
</head>
<body>
	<div id="body-wrapper">
		<div id="main-content">
			<div class="content-box-content">
				<div class="tab-content default-tab" id="tab1">
					<input type="hidden" id="asyncResult" name="asyncResult" value="-1" />
					<input type="hidden" id="asyncResultData" name="asyncResultData" value="-1" /> 
					<input type="hidden" id="asyncResultError" name="asyncResultError" value="-1" />
					<form:form id="inputForm" class="form-horizontal" name="form1" method="post" action="" modelAttribute="dictclass">
						<div class="row">
							<div class="col-md-12 col-sm-12 col-xs-12">
								<div class="form-group">
									<label class="col-md-3 col-sm-3 col-xs-3 control-label">原密码：<span style="color: red">*</span>
									</label>
									<div class="col-md-9 col-sm-9 col-xs-9">
										<input type="password" class="form-control input-sm" name="old_password" id="old_password" placeholder="原密码" />
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-3 col-sm-3 col-xs-3 control-label">新密码：<span style="color: red">*</span>
									</label>
									<div class="col-md-9 col-sm-9 col-xs-9">
										<input type="password" class="form-control input-sm" name="new_password" id="new_password" placeholder="新密码" />
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-3 col-sm-3 col-xs-3 control-label">确认密码：<span style="color: red">*</span>
									</label>
									<div class="col-md-9 col-sm-9 col-xs-9">
										<input type="password" class="form-control input-sm" name="confirm_password" id="confirm_password" placeholder="确认密码" />
									</div>
								</div>
							</div>
						</div>
					</form:form>
				</div>
			</div>
		</div>
	</div>
</body>
</body>
</html>


